package com.xls.controllerr;

import com.xls.dto.Result;
import com.xls.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    GoodsService goodsService;

    @GetMapping("/{id}")
    public Result getGoodsById(@PathVariable("id") Long id){
        return Result.ok(goodsService.getById(id));
    }

    @GetMapping("/list")
    public Result getGoodsList(){
        return Result.ok(goodsService.list());
    }

}
